package gui.lesson01;

import java.awt.*;
import java.awt.event.WindowAdapter;
import java.awt.event.WindowEvent;

public class Testpanel {
    public static void main(String[] args) {
        Frame frame = new Frame();
        Panel panel = new Panel();
        //设置布局
        frame.setLayout(null);
        //设置窗口的坐标和大小，颜色
        frame.setBounds(300,300,500,500);
        frame.setBackground(new Color(32, 198, 198));
        //设置面板的坐标和大小，颜色
        panel.setBounds(50,50,400,400);
        panel.setBackground(new Color(19, 187, 114));
        frame.add(panel);
        frame.setVisible(true);
        frame.setResizable(false);
        //监听事件，监听窗口关闭事件System.exit(0)
        //适配器模式
        frame.addWindowListener(new WindowAdapter() {
            //窗口点击关闭的时候需要做的事情
            @Override
            public void windowClosing(WindowEvent e) {
                //结束程序
                System.exit(0);
            }
        });
    }
}
